import axios from "axios";
import showMessage  from "@/utils/showMessage";

const request = axios.create();//创建一个axios实例

//响应拦截
request.interceptors.response.use(function(resp){
    var data = resp.data;//响应数据体
    
    if(data.code!==0){ //有错误
        showMessage({
            content:data.msg,
            type:'error',
            duration:2000,
        })
        return null;
    }

    return data.data;
    
})

export default request;